package string;

public class Test_String2 {
    /*
    统计大串中小串出现的次数
     */
    public static void main(String[] args) {
        String str = "wzx123wzx123wzx123wzx123";
        //统计123出现的次数
        String s = "wzx";

        int count = 0;//定义计数器变量
        int index = 0;

        //定义循环，判断123是否在str中出现
        while ((index = str.indexOf(s)) != -1) {
            count++;//计数器自增
            str = str.substring(index + s.length());
            System.out.println(str);

        }
        System.out.println(count);

    }
}
